home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / popuphlp.arc / POPUPHLP.PAS < prev   
Pascal/Delphi Source File  |  1986-01-22  |  8KB  |  261 lines

  1. PROGRAM help3278;
  2. {$C-}
  3. {$K-}
  4.  
  5. type
  6.   ScreenLoc  = record
  7.                  character : char;
  8.                  attribute : byte;
  9.                end;
  10.   ScreenLine = array[1..80] of ScreenLoc;
  11.       Screen = array[1..25] of ScreenLine;
  12.     LineType = string[80];
  13.   var
  14.     Mono    : Screen absolute $B000:$0000;
  15.     Colo    : Screen absolute $B800:$0000;
  16.  
  17. type
  18.     arglist_string = string[80];
  19. var
  20.     argvlist : array[1..9] of ^arglist_string;
  21.     argument : arglist_string absolute cseg:$80;
  22. {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
  23.   var
  24.     ScreenSeg : integer;
  25.     color     : boolean;
  26.  
  27.  
  28.  
  29. {VARIABLE SECTION FOR 'POPUPHLP'}
  30.  
  31. type
  32.   text80          = string[80];
  33.   RegType         = record
  34.                       ax,bx,cx,dx,bp,si,di,ds,es,flags:integer
  35.                     end;
  36.   HalfRegType     = record
  37.                       al,ah,bl,bh,cl,ch,dl,dh:byte
  38.                     end;
  39.   IntrType        = record
  40.                       ip,cs : integer
  41.                     end;
  42.  
  43. const
  44.   EntryChar       = 35;                { ALT 'H' }
  45.   Escape          = 0;
  46.   FirstRow        = 1;
  47.   FirstCol        = 1;
  48.   WindowWidth     = 80;
  49.   WindowLength    = 24;
  50.   UserInt         = $67; { 66}            { ***HERE IT IS*** }
  51.                                           {if thelp will not work with your other
  52.                                            resident stuff, change this number to
  53.                                            a free interrupt}
  54.   KybdInt         = $16;
  55.   ProgSize : integer = $A000;             { approx. program size }
  56.  
  57.   Regs    : regtype = (ax:0;bx:0;cx:0;dx:0;bp:0;si:0;di:0;ds:0;es:0;flags:0);
  58.   SaveDS  :integer  = 0;
  59.  
  60. var
  61.   SaveReg    : RegType;
  62.   SaveHalf   : HalfRegType absolute SaveReg;
  63.   HalfReg    : HalfRegType absolute regs;
  64.   i,j,x,y    : integer;
  65.   CursorPos  : integer;
  66.   Selection  : integer;
  67.   savebuf    : array[1..windowwidth] of array[1..windowlength] of integer;
  68.  
  69. var
  70.   Pops    : array[1..3] of screen;
  71.   N, M    : byte;
  72.   PopFile : text;
  73.   OneLine : lineType;
  74.   C, D    : char;
  75.  
  76.  
  77. { MISC. PROCEDURES AND FUNTIONS FOR POPUPHLP }
  78.  
  79.   procedure CheckColor;
  80.   begin
  81.     if (Mem[0000:1040] and 48) <> 48 then
  82.       begin
  83.         ScreenSeg := $B800;
  84.         color     := true;
  85.       end
  86.     else
  87.       begin
  88.         ScreenSeg := $B000;
  89.         color     := false;
  90.       end;
  91.     end;
  92.  
  93. procedure MakeScreen(VAR Line : ScreenLine ; att: byte;theLine : LineType);
  94. var
  95.   row : byte;
  96. begin
  97.   for row := 1 to length(theLine) do
  98.     begin
  99.       Line[row].character := theLine[row];
  100.       Line[row].attribute := att;
  101.     end;
  102.   if length(theLine) < 80 then
  103.     for row := length(theLine) + 1 to 80 do
  104.       begin
  105.         Line[row].character := ' ';
  106.         Line[row].attribute := att;
  107.       end;
  108. end;
  109.  
  110. procedure GetScreensFromFile;
  111. {This is one way to put screens into memory}
  112. var l,rc:integer;
  113.     temp: string[80];
  114. begin
  115.   l := length(argument);
  116.   temp := copy(argument,2,l-1);
  117.   Assign(PopFile,temp);
  118.   {$I-}
  119.   reset(PopFile);
  120.   {$I+}
  121.   rc := IOresult;
  122.   if rc <> 0 then
  123.      begin
  124.      Writeln('Popup help file (',temp, ') doesn''t exist.');
  125.      Writeln('Usage: POPUPHLP FILENAME.HLP');
  126.      inline($CD/$20);
  127.      end;
  128.   For n:= 0 to 24 do
  129.      MakeScreen(Pops[1][N],112,' ');
  130.  
  131.   N := 0;
  132.   while (not EOF(PopFile)) and (N < 25) do
  133.     begin
  134.       N := N + 1;
  135.       readLn(PopFile,OneLine);
  136.       MakeScreen(Pops[1][N],112,OneLine);
  137.     end;
  138.  
  139.   close(PopFile);
  140. end;
  141.  
  142. procedure DOIT;
  143. begin
  144.   CheckColor;
  145.     Pops[(2)] := Mono;
  146.     Pops[(3)] := Colo;
  147.     Mono := Pops[(1)];
  148.     Colo := Pops[(1)];
  149.     savereg.ax := $00;
  150.     Intr(userint,savereg);
  151.     selection := savehalf.ah - 1;
  152.     Mono := Pops[(2)];
  153.     Colo := Pops[(3)];
  154. end;
  155.  
  156. procedure ProcessInt;                  { Start of interupt service }
  157. begin
  158. {when invoked, this procedure saves the registers into the structured constant
  159.  'REGS' and restores the ds from the previously saved integer constant 'saveds'}
  160.  
  161.     inline(
  162.     $53/                               {PUSH BX}
  163.     $BB/regs/                          {MOV BX,OFFSET REGS}
  164.     $2E/$89/$47/$00/                   {CS:MOV [BX]0,AX}
  165.     $58/                               {POP AX}
  166.     $2E/$89/$47/$02/                   {CS:MOV [BX]2,AX}
  167.     $2E/$89/$4F/$04/                   {CS:MOV [BX]4,CX}
  168.     $2E/$89/$57/$06/                   {CS:MOV [BX]6,DX}
  169.     $2E/$89/$6F/$08/                   {CS:MOV [BX]8,BP}
  170.     $2E/$89/$77/$0A/                   {CS:MOV [BX]A,SI}
  171.     $2E/$89/$7F/$0C/                   {CS:MOV [BX]C,DI}
  172.     $2E/$8C/$5F/$0E/                   {CS:MOV [BX]E,DS}
  173.     $2E/$8C/$47/$10/                   {CS:MOV [BX]10,ES}
  174.     $9C/                               {PUSHF}
  175.     $58/                               {POP AX}
  176.     $2E/$89/$47/$12/                   {CS:MOV [BX]12,AX}
  177.     $2E/$8E/$1E/saveds                 {CS:MOV DS,SAVEDS -- PUT PROPER DS}
  178.     );
  179.  
  180.   if halfreg.ah <> 0 then Intr(userint,regs) else
  181.   begin
  182.     Intr(userint,regs);
  183.     if (halfreg.ah = EntryChar) and (halfreg.al = $00) then
  184.     begin
  185.       savereg.ax := $0300;
  186.       savereg.bx := $0;
  187.       Intr($10,savereg);               { get cursor position }
  188.       cursorpos := savereg.dx;
  189.  
  190.       DOIT;
  191.  
  192.       savereg.ax := $0200;
  193.       savereg.bx := $0;
  194.       savereg.dx := cursorpos;
  195.       Intr($10,savereg);               { restore cursor position }
  196.  
  197.       halfreg.ah := 0;
  198.       Intr(userint,regs);
  199.     end;
  200.   end;
  201.  
  202. {when invoked this routine restores the registers from the structure constant}
  203.  
  204.     inline(
  205.     $BB/REGS/                          {MOV BX,OFFSET REGS}
  206.     $2E/$8E/$47/$10/                   {CS:MOV ES,[BX]10}
  207.     $2E/$8E/$5F/$0E/                   {CS:MOV DS,[BX]0E}
  208.     $2E/$8B/$7F/$0C/                   {CS:MOV DI,[BX]0C}
  209.     $2E/$8B/$77/$0A/                   {CS:MOV SI,[BX]0A}
  210.     $2E/$8B/$6F/$08/                   {CS:MOV BP,[BX]08}
  211.     $2E/$8B/$57/$06/                   {CS:MOV DX,[BX]06}
  212.     $2E/$8B/$4F/$04/                   {CS:MOV CX,[BX]04}
  213.     $2E/$8B/$47/$00/                   {CS:MOV AX,[BX]00}
  214.     $2E/$FF/$77/$12/                   {CS:PUSH [BX]12}
  215.     $9D/                               {POPF}
  216.     $2E/$8B/$5F/$02/                   {CS:MOV BX,[BX]02}
  217.     $5D/                               {POP BP}  {restore the stack pointer}
  218.     $5D                                {POP BP}
  219.     );
  220.  
  221.     inline ($CA/$02/$00)               {RETF 02}
  222.  
  223. end;
  224.  
  225.  
  226. { PROGRAM 'POPUPHLP' }                    { Program installation }
  227. begin
  228.   SaveDS := dseg;
  229.   SaveReg.ax := $3500 + UserInt;
  230.   Intr($21,SaveReg);                   { get user interupt }
  231.  
  232.   if SaveReg.es <> $00 then
  233.     begin
  234.     writeln('User Interupt in use -- cant install POPUPHLP.');
  235.     writeln('Reboot system with ALT/CNTL/DELELTE, then retry.');
  236.     end
  237.   else
  238.  
  239.   begin
  240.     GetScreensFromFile;
  241.     writeln('Installing Popup help - Press < ALT "H" > to get help.');
  242.     writeln('                        Press < ESC > to exit help.');
  243.     savereg.ax := $3500 + KybdInt;
  244.     Intr($21,savereg);                 { get keyboard interupt }
  245.  
  246.     savereg.ax := $2500 + UserInt;
  247.     savereg.ds := savereg.es;
  248.     savereg.dx := savereg.bx;
  249.     Intr($21,savereg);                 { put in user interupt }
  250.  
  251.     savereg.ax := $2500 + KybdInt;
  252.     savereg.ds := cseg;
  253.     savereg.dx := ofs(ProcessInt);
  254.     Intr($21,savereg);                 { install our interupt processor }
  255.  
  256.     savereg.dx := ProgSize;
  257.     Intr($27,savereg);                 { terminate and stay resident }
  258.   end;
  259.   inline($CD/$20);                     { terminate if interupt in use }
  260. end.
  261.